package cn.stu.cms.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * 文件
 *
 * @author gh
 * @date 2023/10/18
 */
@Data
@ToString
@EqualsAndHashCode
public class File extends BaseEntity implements Serializable {

    /**
     * 主键ID
     */
    @NotNull(message = "文件ID不能为空", groups = {Update.class})
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    /**
     * 文件名
     */
    private String name;
    /**
     * 路径
     */
    private String path;
    /**
     * 类型
     */
    private String type;
    /**
     * 大小
     */
    private String size;
    /**
     * 用户ID
     */
    private Long userId;

    /**
     * 父级ID
     */
    @NotNull(message = "父级目录ID不能为空", groups = {CreateFile.class, CreateFolder.class})
    private Long parentId;

    /**
     * 是否共享
     */
    private Boolean shared;


    /**
     * content-type
     */
    private String contentType;

    public boolean isFolder() {
        return "文件夹".equals(this.type);
    }

    public interface CreateFile {
    }

    public interface CreateFolder {
    }

    public interface Update {
    }

}